/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author CUNEYT
 *
 * This class represents the museum/gallery which is supposed to be monitored by the Curator agent.
 *
 */
public class ArtMuseum {

    private ArrayList<Artifact> artifacts = null;

    public ArtMuseum() {
        this.artifacts = new ArrayList<Artifact>();
    }

    public Artifact get(String id) {
        Artifact result = null;
        for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext();) {
            Artifact artifact = it.next();
            if (artifact.getId().equals(id)) {
                result = artifact;
                break;
            }
        }
        return result;
    }

    public ArrayList<String> getArtifactsByCategory(String cat) {
        ArrayList<String> result = new ArrayList<String>();

        for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext();) {
            Artifact artifact = it.next();
            if (artifact.getCategory().equals(cat)) {
                result.add(artifact.toString());
            }
        }
        return result;
    }

    public ArrayList<String> getArtifactsByGenre(String genre) {
        ArrayList<String> result = new ArrayList<String>();

        for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext();) {
            Artifact artifact = it.next();
            if (artifact.getGenre().equals(genre)) {
                result.add(artifact.toString());
            }
        }
        return result;
    }

    public ArrayList<String> getArtifactsByCreator(String creator) {
        ArrayList<String> result = new ArrayList<String>();

        for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext();) {
            Artifact artifact = it.next();
            if (artifact.getCreator().equals(creator)) {
                result.add(artifact.toString());
            }
        }
        return result;
    }

    public ArrayList<String> getArtifactsByName(String name) {
        ArrayList<String> result = new ArrayList<String>();

        for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext();) {
            Artifact artifact = it.next();
            if (artifact.getName().equals(name)) {
                result.add(artifact.toString());
            }
        }
        return result;
    }

    public void addArtifact(Artifact a) {
        if (!artifacts.contains(a)) {
            artifacts.add(a);
        }
    }

    public ArrayList<Artifact> getArtifacts() {
        return artifacts;
    }

    public void setArtifacts(ArrayList<Artifact> artifacts) {
        this.artifacts = artifacts;
    }
}
